//
//  GdMapFlutterStreamManager.m
//  o_amap
//
//  Created by Q神 on 2021/3/31.
//

#import "GdMapFlutterStreamManager.h"

@implementation GdMapFlutterStreamManager

+ (instancetype)shareInstance {
    static dispatch_once_t onceToken;
    static GdMapFlutterStreamManager *manager = nil;
    dispatch_once(&onceToken, ^{
        manager = [[super allocWithZone:nil] init];
        GdMapFlutterStreamHandler *handler = [[GdMapFlutterStreamHandler alloc] init];
        manager.steamHandler = handler;
    });
    return manager;
}

+ (id)allocWithZone:(NSZone *)zone {
    return [self shareInstance];
}

- (id)copyWithZone:(NSZone *)zone {
    return [[self class] shareInstance];
}

- (id)mutableCopyWithZone:(NSZone *)zone {
    return [[self class] shareInstance];
}

@end


@implementation GdMapFlutterStreamHandler

#pragma mark -- FlutterStreamHandler 代理

- (FlutterError *)onListenWithArguments:(id)arguments eventSink:(FlutterEventSink)events {
    /// 从原生传递给 flutter 消息
    if (events) {
        self.eventSink = events;
    }
    return nil;
}

/// 不再需要向Flutter传递消息
- (FlutterError *)onCancelWithArguments:(id)arguments {
    return nil;
}

@end
